package com.naiterui.ehp.bs.agent.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * <pre>
 * 订单表
 * </pre>
 *
 * @author zhouyanxin
 * @date 2019/1/11 下午11:19
 * @since 1.0.0
 */
@Data
@Entity
@NoArgsConstructor
@Table(name = "e_order")
public class Order implements java.io.Serializable {

    ///////////////////////////// 支付状态 /////////////////////////////////

    /**
     * 支付状态 未支付
     */
    public static final int PAY_STATUS_WAIT_PAY = 0;

    /**
     * 支付状态 已支付
     */
    public static final int PAY_STATUS_PAY = 1;
    /**
     * 支付状态 退款
     */
    public static final int PAY_STATUS_REFUND = 2;

    ///////////////////////////// 是否需要发票 /////////////////////////////////
    /**
     * 是否需要发票 不需要
     */
    public static final int INVOICE_NO_NEED = 0;

    /**
     * 是否需要发票 需要
     */
    public static final int INVOICE_NEED = 1;

    ///////////////////////////// 取消原因 /////////////////////////////////
    // 取消原因(0:未取消,1:未支付取消,2:支付后取消3:确认后取消,4:测试订单)
    /**
     * 取消原因 未取消
     */
    public static final int CANCEL_TYPE_NORMAL = 0;
    /**
     * 取消原因 未支付取消
     */
    public static final int CANCEL_TYPE_NO_PAY = 1;
    /**
     * 取消原因 支付后取消
     */
    public static final int CANCEL_TYPE_PAY = 2;
    /**
     * 取消原因 确认后取消
     */
    public static final int CANCEL_TYPE_CONFIRM = 3;
    /**
     * 取消原因 测试订单
     */
    public static final int CANCEL_TYPE_TEST = 4;
    private static final long serialVersionUID = 6514609862376473648L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    /**
     * 订单号
     */
    @Column(name = "order_sn", nullable = false, length = 30)
    private String orderSn;
    /**
     * 下单用户id
     */
    @Column(name = "user_id", nullable = false)
    private Long userId;
    /**
     * 仓库ID
     */
    @Column(name = "warehouse_id")
    private Long warehouseId;
    /**
     * 订单状态(1:待付款,2:待审核,3:订单审核完成,4:库房分配完成,5:药店已接收,6:订单已发货,7:订单已签收,8:已取消)
     */
    @Column(name = "order_status", nullable = false)
    private Integer orderStatus;
    /**
     * 支付状态(0:未支付,1:已支付,2:退款)
     */
    @Column(name = "pay_status", nullable = false)
    private Integer payStatus;
    /**
     * 支付类型(1:微信支付,2:货到付款)
     */
    @Column(name = "pay_type", nullable = false)
    private Integer payType;
    /**
     * 取消原因(0:未取消,1:未支付取消,2:支付后取消3:确认后取消,4:测试订单)
     */
    @Column(name = "cancel_reason", nullable = true)
    private Integer cancelReason;
    /**
     * 商品总价(分)
     */
    @Column(name = "total_amount", nullable = true)
    private Integer totalAmount;
    /**
     * 实付(分)
     */
    @Column(name = "real_pay", nullable = false)
    private Integer realPay;
    /**
     * 邮费(分)
     */
    @Column(name = "freight", nullable = false)
    private Integer freight;
    /**
     * 优惠券抵扣(分)
     */
    @Column(name = "coupon_pay", nullable = false)
    private Integer couponPay;
    /**
     * 是否需要发票(0:不需要,1:需要)
     */
    @Column(name = "need_invoice", nullable = false)
    private Integer needInvoice;
    /**
     * 发票抬头
     */
    @Column(name = "invoice_title", nullable = true, length = 40)
    private String invoiceTitle;
    /**
     * 发票明细
     */
    @Column(name = "invoice_content", nullable = true, length = 10)
    private String invoiceContent;
    /**
     * 发票邮箱
     */
    @Column(name = "invoice_email", nullable = true, length = 40)
    private String invoiceEmail;
    /**
     * 发票电话
     */
    @Column(name = "invoice_phone", nullable = true, length = 20)
    private String invoicePhone;
    /**
     * 发票税号
     */
    @Column(name = "invoice_tax_no", nullable = true, length = 40)
    private String invoiceTaxNo;
    /**
     * 拣货人
     */
    @Column(name = "pickup_man", nullable = true, length = 20)
    private String pickupMan;
    /**
     * 发货时间
     */
    @Column(name = "send_time", nullable = true)
    private Date sendTime;
    /**
     * 订单完成时间
     */
    @Column(name = "completed_time")
    private Date completedTime;

    /**
     * 订单备注
     */
    @Column(name = "remark", length = 100)
    private String remark;

    /**
     * 创建时间
     */
    @Column(name = "created_at")
    private Date createdAt;

    /**
     * 创建人
     */
    @Column(name = "created_by")
    private String createdBy;

    /**
     * 修改时间
     */
    @Column(name = "changed_at")
    private Date changedAt;

    /**
     * 修改人
     */
    @Column(name = "changed_by")
    private String changedBy;

    /**
     * 乐观锁
     */
    @Version
    private Integer version;

}
